package com.sztz.mapstruct.B简单转换;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * CarMapper
 *
 * @author yyf
 * @email yeyafei@hotmail.com
 */
@Mapper
public interface CarMapper {

    CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);

    /**
     * 简单转换
     * 默认拷贝所有同名属性
     * ignore: 忽略拷贝
     * defaultValue: 如果映射为空则赋值默认值
     * constant: 指定映射值
     *
     * @param car
     * @return CarDto
     */
    @Mapping(target = "age", ignore = true)
    @Mapping(target = "owner", defaultValue = "阿坤")
    @Mapping(target = "sex", constant = "男")
    CarDTO toDto(Car car);
}
